<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box">

    </div>
</body>
</html>
<script>
    var xhr =new XMLHttpRequest();
    xhr.open("GET","json.php");
    xhr.send();
    xhr.onreadystatechange =function(){
        if(xhr.readyState ===4){
            var obj = JSON.parse(xhr.responseText)
            var html ="";
            for(var attr in obj){
                html +="<p>key值 ：" +attr+ ",value值为"+obj[attr]+"</p>";
            }
            document.querySelector("#box").innerHTML =html;
        }
    }
</script>